package com.cfpl.dealer_service.controller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cfpl.DTO.PageQueryConditionDTO;
import com.cfpl.dealer_service.VO.DistributeVO;
import com.cfpl.dealer_service.service.DistributeInformationService;
import com.cfpl.project_common.pojo.DistributeInformation;
import com.cfpl.project_common.result.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: LYP
 * @Date: 2023/11/11 - 14:58
 * @Description: com.cfpl.dealer_service.controller
 * @version: 1.0
 */
@RestController
@Slf4j
@Api(tags = "分发产品接口")
@RequestMapping("/distribute")
public class DistributeController {

    @Autowired
    private DistributeInformationService distributeService;

    @ApiOperation("添加产品分发记录")
    @PostMapping("/addDistributeRecordInfo")
    public BaseResult addDistributeRecordInfo(DistributeInformation distributeInformation){
        distributeService.addDistributeRecordInfo(distributeInformation);
        return BaseResult.ok();
    }

    /**
     * 产品名称查 :这种产品的分发记录
     * 经销商查询 :这家公司的分发记录
     *
     * 结果展示： 编号, 经销商, 发货地, 产品名称, 产品单价, 产品数量, 价格总计
     * @return
     */
    @ApiOperation("分页查询产品分发记录")
    @PostMapping("/pageQueryDistribution")
    public BaseResult<IPage<DistributeVO>> pageQueryDistribution(PageQueryConditionDTO pageQuery){
        IPage<DistributeVO> page = new Page<>(pageQuery.getCurrentPage(), pageQuery.getPageSize());
        IPage<DistributeVO> distributeVOIPage = distributeService.pageQueryDistribute(page,pageQuery.getQueryCondition());
        return BaseResult.ok(distributeVOIPage);
    }



}
